<template>
  <div>
    <!-- <VRow v-if="false" class="lf-config-row">
      <VCol cols="12">
        <VTextField
          v-model="elId"
          class="lf-config-item"
          counter
          maxlength="50"
          color="success"
          hint="表达式ID"
          label="表达式ID"
        />
      </VCol>
      <VCol cols="12">
        <VTextField
          v-model="elName"
          class="lf-config-item"
          counter
          maxlength="50"
          color="success"
          hint="表达式名称"
          label="表达式名称"
        />
      </VCol>
      <VCol cols="12">
        <VTextField
          v-model="el"
          class="lf-config-item"
          counter
          maxlength="512"
          color="success"
          hint="表达式"
          label="表达式"
        />
      </VCol>
      <VCol cols="12">
        
      </VCol>
    </VRow> -->
    <FlowChart />
  </div>
</template>

<script setup>
import { ref } from 'vue'
import FlowChart from '@/views/liteflow/logic/FlowChart.vue'

const props = defineProps({		
  currRow: Object,
  addUrl: String,
  updateUrl: String,
})

const emits = defineEmits(['refreshPage'])

const addUrl = ref(props.addUrl)
const updateUrl = ref(props.updateUrl)

const currRow = ref(props.currRow)
const row = currRow.value

const isEdit = ref(!!row.id)

const id = ref(row.id || '')
const elId = ref(row.elId || '')
const elName = ref(row.elName || '')
const el = ref(row.el || '')

const getUrl = () => {
  if(isEdit.value){
    return updateUrl.value
  }
  
  return addUrl.value
}

const saveItem = async () => {
  const res = await $ivyApi.post(getUrl(),{
    id: id.value,
    elId: elId.value,
    elName: elName.value,
    el: el.value,
  })
  emits('refreshPage', res)
}

defineExpose({
  saveItem,
})

</script>


